<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>img底部5px问题</title>
</head>
<style>
    .box {
        margin-bottom: 10px;
        width: 200px;
        position: relative;
        font-size: 0;
        /* line-height: 0; */
    }
    
    img {
        width: 100%;
    }
    
    .selected {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
    }
</style>

<body>
    <div>
        img的属性vertical-align（默认值baseline）导致蒙层有5px的底部,解决方式
        <pre>
    父元素：
            font-size:0;
            line-height:0;
    子元素img:
            dispaly:block;
            vertical-align:middle/top/bottom；
</pre>
    </div>
    <div class="box">
        <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimages.h128.com%2Fupload%2F201906%2F20%2F201906202330039685.jpg%3Fx-oss-process%3Dimage%2Fresize%2Cm_lfit%2Cw_1421%2Fquality%2Cq_100%2Fformat%2Cjpg&refer=http%3A%2F%2Fimages.h128.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1638496132&t=5fb79139bc9af535b256bd7b4d248618"
            alt="" />
    </div>
    <div class="box">
        <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimages.h128.com%2Fupload%2F201906%2F20%2F201906202330039685.jpg%3Fx-oss-process%3Dimage%2Fresize%2Cm_lfit%2Cw_1421%2Fquality%2Cq_100%2Fformat%2Cjpg&refer=http%3A%2F%2Fimages.h128.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1638496132&t=5fb79139bc9af535b256bd7b4d248618"
            alt="" />
        <div class="selected"></div>
    </div>
</body>

</html>